{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="user_name" class="layui-input search" name="user_name" value="" placeholder="名称|手机号|个人简介"/>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_status" class="layui-input">
                                <option value="">不限状态</option>
                                <option value="1">正常</option>
                                <option value="2">冻结</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px">
                            <select name="user_auth" class="layui-input">
                                <option value="">不限角色</option>
                                <option value="1">销售代表</option>
                                <option value="2">管理经理</option>
                            </select>
                        </div>
                        <div class="layui-input-inline" style="margin-top: 5px;">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="input-group" >
                        <button class="btn " type="button" onclick="history.go(-1)">
                            <i class="fa fa-backward"></i> 返回
                        </button>
                        <button class="btn btn-primary" type="button" onclick="wk.layer_show('添加团队', '{:url('addTeamuser')}')">
                        <i class="fa fa-plus"></i> 添加成员
                        </button>
                        <button type="button" class="btn btn-primary layuiBtn" data-type="tttttt">
                        <i class="fa fa-upload"></i> 批量转移
                        </button>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <button class="btn btn-primary" type="button" onclick="wk.layer_show('导入成员', '{:url('excelin')}')">
                        <i class="fa fa-file-excel-o"></i> 导入成员
                        </button>
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 导出成员数据 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllU"><i class="fa fa-external-link"></i> 导出选中数据</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelectU"><i class="fa fa-external-link"></i> 全部导出</a></li>
                        </ul>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <!--<div class="col-sm-12">-->
                    <!--<div class="input-group" >-->
                        <!--<button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">-->
                            <!--<i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>-->
                        <!--</button>-->
                        <!--<ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">-->
                            <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAll"><i class="fa fa-external-link"></i> 批量导出</a></li>-->
                            <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelAllNoSelect"><i class="fa fa-external-link"></i> 全部导出</a></li>-->
                        <!--</ul>-->
                    <!--</div>-->
                <!--</div>-->
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>
                    <!--修改状态模板-->
                    <!--<script type="text/html" id="staBar">-->
                    <!--<input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="上架中|已下架" lay-filter="OnOff" {{ d.school_status == 1 ? 'checked' : '' }} >-->
                    <!--</script>-->

                    <!--状态显示模板-->
                    <!--<script type="text/html" id="imgTpl">-->
                    <!--<img src="{{d.rb_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />-->
                    <!--</script>-->
                    <!--操作模板-->
                    <script type="text/html" id="user_status">
                    {{# if(d.user_status == 1){ }}
                    正常
                    {{# } }}
                    {{# if(d.user_status == 2){ }}
                    冻结
                    {{# } }}
                    </script>
                    <script type="text/html" id="user_sex">
                    {{# if(d.user_sex == 1){ }}
                    男
                    {{# } }}
                    {{# if(d.user_sex == 2){ }}
                    女
                    {{# } }}
                    </script>
                    <script type="text/html" id="user_auth">
                    {{# if(d.user_auth == 1){ }}
                    销售代表
                    {{# } }}
                    {{# if(d.user_auth == 2){ }}
                    管理经理
                    {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.layer_show('编辑', '{:url('editTeamuser')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="编辑">编辑</a>
                        <a href="javascript:;" onclick="wk.layer_show('转移团队', '{:url('editTeamFor')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="转移团队">转移团队</a>
                        {{# if(d.user_status == 1){ }}
                        <a href="javascript:;" onclick="wk.layer_show('区域管理', '{:url('Comuser/userAreas')}?user_id={{d.user_id}}')" class="btn btn-primary btn-xs m-r-xs" title="区域管理">区域管理</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('downTeamuser')}','确定冻结吗?')" class="btn btn-primary btn-xs m-r-xs" title="冻结">冻结</a>
                        {{# } }}
                        {{# if(d.user_status == 2){ }}
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('upTeamuser')}','确定启用吗?')" class="btn btn-warning btn-xs m-r-xs" title="启用">启用</a>
                        <a href="javascript:;" onclick="wk.confirm('{{d.user_id}}','{:url('teamDeluser')}','确定删除吗?')" class="btn btn-danger btn-xs m-r-xs" title="删除">删除</a>
                        {{# } }}
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("company/seeTeamUsers")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 300]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left'},
                  {type:'numbers', width: 70, title: '序号'}
                , {field: 'user_id', width: 70, title: '用户id', align: 'center'}
                , {field: 'user_username', width: '', title: '用户名称', align: 'center'}
                , {field: 'user_phone', width: '', title: '用户电话', align: 'center'}
                , {field: 'user_sex', width: 90, title: '性别', align: 'center',templet: '#user_sex'}
                , {field: 'user_birthday', width: 90, title: '生日', align: 'center'}
                , {field: 'user_job_desc', width: 90, title: '简介', align: 'center'}
                , {field: 'user_auth', width: 90, title: '团队角色', align: 'center',templet: '#user_auth'}
                , {field: 'user_status', width: 90, title: '用户状态', align: 'center',templet: '#user_status'}
                , {field: 'user_time', width: '', title: '加入时间', align: 'center'}
                , {fixed: 'right', width:250, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            ,done: function (res, curr, count) {
                $('.img-circle').viewer({
                    url: 'data-original',
                });
            }
        });
        //批量操作
        var $ = layui.$, active = {
            //批量导出订单
            excelAllU:function () {
                wk.excelAll(getIds(),$('.layui-input').serialize(),"{:url('outExcelUser')}");
            },
            //全部导出
            excelAllNoSelectU:function () {
                wk.excelAll('all',$('.layui-input').serialize(),"{:url('outExcelUser')}");
            },
            //全部导出
            tttttt:function () {
                wk.layer_show('批量转移团队', "{:url('editTeamFor')}?user_id="+getIds());
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['user_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>